﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;

namespace Reborn_WorldServer.PendingClients
{
    public class PendingClient
    {
        public int userID;
        public int characterID;
        public string uid;
        public int mapID;
        public int instance;
        public int mapX;
        public int mapY;
        public bool isTransfer;

        public Timer clientConnectTimeout = new Timer(10000);

        public PendingClient(int UserID, int CharacterID, string UID, int MapID, int Instance, int MapX, int MapY, bool IsTransfer)
        {
            clientConnectTimeout.Elapsed += new ElapsedEventHandler(clientConnectTimeout_Elapsed);
            clientConnectTimeout.AutoReset = false;
            clientConnectTimeout.Start();

            userID = UserID;
            characterID = CharacterID;
            uid = UID;
            mapID = MapID;
            instance = Instance;
            mapX = MapX;
            mapY = MapY;
            isTransfer = IsTransfer;
        }

        private void clientConnectTimeout_Elapsed(object sender, ElapsedEventArgs e)
        {
            Managers.pendingClientsManager.RemovePendingClient(this);
            clientConnectTimeout.Dispose();
        }

        public void killTimeout()
        {
            try
            {
                clientConnectTimeout.Stop();
                clientConnectTimeout.Dispose();
            }
            catch { }
        }
    }
}
